package com.xand.bt.terminal.ui;

import java.awt.Component;

import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;

import com.xand.bt.terminal.ui.depth.MarketDepthTableDisplay;
import com.xand.bt.terminal.ui.logger.LoggerTableDisplay;
import com.xand.bt.terminal.ui.ticker.MarketTickerDisplay;
import com.xand.bt.terminal.ui.toolbar.MainToolbarDisplay;

public class MainWindow extends JFrame {
	
	private static final long serialVersionUID = 1791136229489526983L;

	private MarketDepthTableDisplay marketDepthTable;
	
	private MarketTickerDisplay marketTickerDisplay;
	
	private LoggerTableDisplay loggerTableDisplay;
	
	private MainToolbarDisplay mainToolbarDisplay;
	
	public MainWindow() {
		super();
		this.setSize(UIConst.MAIN_WINDOW_SIZE);
		this.setResizable(UIConst.MAIN_WINDOW_RESIZABLE);
		
		this.marketDepthTable = new MarketDepthTableDisplay();
		this.marketTickerDisplay = new MarketTickerDisplay();
		this.loggerTableDisplay = new LoggerTableDisplay();
		this.mainToolbarDisplay = new MainToolbarDisplay();
		
		this.createContentPane();
		
		this.addWindowListener(new MainWindowListener());
		this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		
		this.setVisible(true);
	}
	
	public MarketDepthTableDisplay getMarketDepthTable() {
		return this.marketDepthTable;
	}
	
	public LoggerTableDisplay getLoggerTableDisplay() {
		return this.loggerTableDisplay;
	}
	
	private void createContentPane() {
		
		JPanel content = new JPanel();
		
		JPanel centerPanel = new JPanel();
		
		BoxLayout centerPanelLayout = new BoxLayout(centerPanel, BoxLayout.X_AXIS);
		
		centerPanel.setBorder(UIConst.MAIN_WINDOW_CENTER_PANEL_BORDER);
		centerPanel.setPreferredSize(UIConst.MAIN_WINDOW_CENTER_PANEL_SIZE);
		centerPanel.add(this.marketDepthTable.getPanel());
		centerPanel.add(this.marketTickerDisplay.getPanel());
		
		content.add(this.mainToolbarDisplay.getPanel());
		content.add(centerPanel);
		content.add(this.loggerTableDisplay.getPanel());
		
		super.setContentPane(content);
		
	}
	
}
